namespace pos.entity
{
using System;
using System.Data;
using System.Configuration;
using System.Text;
using System.Data.OleDb;
using System.Collections;
using System.Windows.Forms;
using NHibernate;
using NHibernate.Criterion;
/// <summary>
/// t_hstock 的摘要说明
/// </summary>
public class t_hstock:IEntityUtil
{
//   结算状态值的哈希表 
	private static Hashtable m_enum_settleState;
	public static Hashtable  enum_settleState
	{
		get{return m_enum_settleState;}
	}
	public const int SETTLEYES=1;
	public const int SETTLENO=0;
	//   列名称哈希表 
	private static Hashtable m_colLabels;    	 
	public static Hashtable colLabels//
	{
		get{return m_colLabels;}
	}
	//表字段名称哈希表
	private static ArrayList m_colNames;     
	public static ArrayList  colNames　
	{
		get{return m_colNames;}
	}
	private Hstock __hstock;
	public long seqID  
	{
		get{return __hstock.seqID;}
		set{ __hstock.seqID=value;}
	}
	public DateTime stockTime  
	{
		get{return __hstock.stockTime;}
		set{ __hstock.stockTime=value;}
	}
	public long commoditySeqID  
	{
		get{return __hstock.commoditySeqID;}
		set{ __hstock.commoditySeqID=value;}
	}
	public String commodityID  
	{
		get{return __hstock.commodityID;}
		set{ __hstock.commodityID=value;}
	}
	public String commodityName  
	{
		get{return __hstock.commodityName;}
		set{ __hstock.commodityName=value;}
	}
	public double stockBoxAmount  
	{
		get{return __hstock.stockBoxAmount;}
		set{ __hstock.stockBoxAmount=value;}
	}
	public double stockAmount  
	{
		get{return __hstock.stockAmount;}
		set{ __hstock.stockAmount=value;}
	}
	public double stockMoney  
	{
		get{return __hstock.stockMoney;}
		set{ __hstock.stockMoney=value;}
	}
	public double stockPrice  
	{
		get{return __hstock.stockPrice;}
		set{ __hstock.stockPrice=value;}
	}
	public double unitAmount  
	{
		get{return __hstock.unitAmount;}
		set{ __hstock.unitAmount=value;}
	}
	public long dealer  
	{
		get{return __hstock.dealer;}
		set{ __hstock.dealer=value;}
	}
	public double saleAmount  
	{
		get{return __hstock.saleAmount;}
		set{ __hstock.saleAmount=value;}
	}
	public double saleMoney  
	{
		get{return __hstock.saleMoney;}
		set{ __hstock.saleMoney=value;}
	}
	public double returnedAmount  
	{
		get{return __hstock.returnedAmount;}
		set{ __hstock.returnedAmount=value;}
	}
	public double returnedMoney  
	{
		get{return __hstock.returnedMoney;}
		set{ __hstock.returnedMoney=value;}
	}
	public double storageAmount  
	{
		get{return __hstock.storageAmount;}
		set{ __hstock.storageAmount=value;}
	}
	public double storageMoney  
	{
		get{return __hstock.storageMoney;}
		set{ __hstock.storageMoney=value;}
	}
	public double lossMoney  
	{
		get{return __hstock.lossMoney;}
		set{ __hstock.lossMoney=value;}
	}
	public DateTime addTime  
	{
		get{return __hstock.addTime;}
		set{ __hstock.addTime=value;}
	}
	public int settleState  
	{
		get{return __hstock.settleState;}
		set{ __hstock.settleState=value;}
	}
	private static  HstockDao dao=(HstockDao)SpringContext.Context.GetObject("HstockDao");
	public static HstockDao DAO
	{
		get{return dao;}
		
	}
	
	public t_hstock()
	{
		__hstock=new Hstock();
	  	seqID=consts.long_min;
	  	stockTime=DateTime.Now;
	  	commoditySeqID=consts.long_min;
	  	commodityID="";
	  	commodityName="";
	  	stockBoxAmount=consts.double_min;
	  	stockAmount=consts.double_min;
	  	stockMoney=consts.double_min;
	  	stockPrice=consts.double_min;
	  	unitAmount=consts.double_min;
	  	dealer=consts.long_min;
	  	saleAmount=consts.double_min;
	  	saleMoney=consts.double_min;
	  	returnedAmount=consts.double_min;
	  	returnedMoney=consts.double_min;
	  	storageAmount=consts.double_min;
	  	storageMoney=consts.double_min;
	  	lossMoney=0;
	  	addTime=DateTime.Now;
	  	settleState=0;
	  // dao=(HstockDao)SpringContext.Context.GetObject("HstockDao");
	   if(m_colLabels==null)
	   {
		m_colLabels = new Hashtable();
        m_colNames= new ArrayList();
		m_colLabels.Add("seqID", @"编号");
		colNames.Add("seqID");
		m_colLabels.Add("stockTime", @"入库时间");
		colNames.Add("stockTime");
		m_colLabels.Add("commoditySeqID", @"商品编号");
		colNames.Add("commoditySeqID");
		m_colLabels.Add("commodityID", @"商品条形码");
		colNames.Add("commodityID");
		m_colLabels.Add("commodityName", @"商品名称");
		colNames.Add("commodityName");
		m_colLabels.Add("stockBoxAmount", @"箱数");
		colNames.Add("stockBoxAmount");
		m_colLabels.Add("stockAmount", @"进货数量");
		colNames.Add("stockAmount");
		m_colLabels.Add("stockMoney", @"进货金额");
		colNames.Add("stockMoney");
		m_colLabels.Add("stockPrice", @"进货价格");
		colNames.Add("stockPrice");
		m_colLabels.Add("unitAmount", @"每箱件数");
		colNames.Add("unitAmount");
		m_colLabels.Add("dealer", @"供应商");
		colNames.Add("dealer");
		m_colLabels.Add("saleAmount", @"销售数量");
		colNames.Add("saleAmount");
		m_colLabels.Add("saleMoney", @"销售金额");
		colNames.Add("saleMoney");
		m_colLabels.Add("returnedAmount", @"出库数量");
		colNames.Add("returnedAmount");
		m_colLabels.Add("returnedMoney", @"出库金额");
		colNames.Add("returnedMoney");
		m_colLabels.Add("storageAmount", @"库存数量");
		colNames.Add("storageAmount");
		m_colLabels.Add("storageMoney", @"库存金额");
		colNames.Add("storageMoney");
		m_colLabels.Add("lossMoney", @"损耗金额");
		colNames.Add("lossMoney");
		m_colLabels.Add("addTime", @"添加时间");
		colNames.Add("addTime");
		m_colLabels.Add("settleState", @"结算状态");
		colNames.Add("settleState");
		m_enum_settleState= new Hashtable();
		m_enum_settleState.Add("1", @"已结算");
		m_enum_settleState.Add("0", @"未结算");
	  }
	
	}
	public t_hstock(Hstock entity )
	{
		__hstock=entity;
		
	  // dao=(HstockDao)SpringContext.Context.GetObject("HstockDao");
	   if(m_colLabels==null)
	   {
		m_colLabels = new Hashtable();
        m_colNames= new ArrayList();
		m_colLabels.Add("seqID", @"编号");
		colNames.Add("seqID");
		m_colLabels.Add("stockTime", @"入库时间");
		colNames.Add("stockTime");
		m_colLabels.Add("commoditySeqID", @"商品编号");
		colNames.Add("commoditySeqID");
		m_colLabels.Add("commodityID", @"商品条形码");
		colNames.Add("commodityID");
		m_colLabels.Add("commodityName", @"商品名称");
		colNames.Add("commodityName");
		m_colLabels.Add("stockBoxAmount", @"箱数");
		colNames.Add("stockBoxAmount");
		m_colLabels.Add("stockAmount", @"进货数量");
		colNames.Add("stockAmount");
		m_colLabels.Add("stockMoney", @"进货金额");
		colNames.Add("stockMoney");
		m_colLabels.Add("stockPrice", @"进货价格");
		colNames.Add("stockPrice");
		m_colLabels.Add("unitAmount", @"每箱件数");
		colNames.Add("unitAmount");
		m_colLabels.Add("dealer", @"供应商");
		colNames.Add("dealer");
		m_colLabels.Add("saleAmount", @"销售数量");
		colNames.Add("saleAmount");
		m_colLabels.Add("saleMoney", @"销售金额");
		colNames.Add("saleMoney");
		m_colLabels.Add("returnedAmount", @"出库数量");
		colNames.Add("returnedAmount");
		m_colLabels.Add("returnedMoney", @"出库金额");
		colNames.Add("returnedMoney");
		m_colLabels.Add("storageAmount", @"库存数量");
		colNames.Add("storageAmount");
		m_colLabels.Add("storageMoney", @"库存金额");
		colNames.Add("storageMoney");
		m_colLabels.Add("lossMoney", @"损耗金额");
		colNames.Add("lossMoney");
		m_colLabels.Add("addTime", @"添加时间");
		colNames.Add("addTime");
		m_colLabels.Add("settleState", @"结算状态");
		colNames.Add("settleState");
		m_enum_settleState= new Hashtable();
		m_enum_settleState.Add("1", @"已结算");
		m_enum_settleState.Add("0", @"未结算");
	  }
	
	}
	public Object uniqueResult(DetachedCriteria dc)
    {
        return dao.uniqueResult(dc);
    }
	 public DetachedCriteria DC 
     {
        	get{return DetachedCriteria.For(typeof(Hstock));}
     }
	public const string ENTITYNAME="t_hstock";
	public const int SEQN0=133;
	
    public void checkAdd()
    {
		int len;
	//try{Convert.ToInt64(seqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	seqID<consts.long_min+1)
			throw (new Exception("请输入编号"));
 if(				(				  string.Format("{0}",seqID)				  )=="0")
	 throw (new Exception("编号是主健，框架要求值不能为0"));				

	//try{Convert.ToDateTime(stockTime);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	stockTime.ToString().CompareTo(consts.datetime_min) <= 0 )
			throw (new Exception("请输入入库时间"));

	//try{Convert.ToInt64(commoditySeqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	commoditySeqID<consts.long_min+1)
			throw (new Exception("请输入商品编号"));

	
	len=commodityID.Trim().Length;
	if(len>50)
		 throw (new Exception("商品条形码字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品条形码不能为空!"));	
	

	
	len=commodityName.Trim().Length;
	if(len>50)
		 throw (new Exception("商品名称字符长度最长不能超过50,当前长度为"+len.ToString()));	
	

	//try{Convert.ToDouble(stockBoxAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	stockBoxAmount<consts.double_min+1)
			throw (new Exception("请输入箱数"));
		if(stockBoxAmount>0)
			stockBoxAmount+=0.000001;
		if(stockBoxAmount<0)
			stockBoxAmount-=0.000001;
		
			if(((long)((stockBoxAmount)*100 ))*10!=(long)((stockBoxAmount)*1000) )
				throw (new Exception("箱数小数精度不能大于2位stockBoxAmount="+stockBoxAmount.ToString()));
		if(stockBoxAmount>0)
			stockBoxAmount-=0.000001;
		if(stockBoxAmount<0)
			stockBoxAmount+=0.000001;
	

	//try{Convert.ToDouble(stockAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	stockAmount<consts.double_min+1)
			throw (new Exception("请输入进货数量"));
		if(stockAmount>0)
			stockAmount+=0.000001;
		if(stockAmount<0)
			stockAmount-=0.000001;
		
			if(((long)((stockAmount)*100 ))*10!=(long)((stockAmount)*1000) )
				throw (new Exception("进货数量小数精度不能大于2位stockAmount="+stockAmount.ToString()));
		if(stockAmount>0)
			stockAmount-=0.000001;
		if(stockAmount<0)
			stockAmount+=0.000001;
	

//do not check stockMoney 

	//try{Convert.ToDouble(stockPrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	stockPrice<consts.double_min+1)
			throw (new Exception("请输入进货价格"));
		if(stockPrice>0)
			stockPrice+=0.000001;
		if(stockPrice<0)
			stockPrice-=0.000001;
		
			if(((long)((stockPrice)*100 ))*10!=(long)((stockPrice)*1000) )
				throw (new Exception("进货价格小数精度不能大于2位stockPrice="+stockPrice.ToString()));
		if(stockPrice>0)
			stockPrice-=0.000001;
		if(stockPrice<0)
			stockPrice+=0.000001;
	

	//try{Convert.ToDouble(unitAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	unitAmount<consts.double_min+1)
			throw (new Exception("请输入每箱件数"));
		if(unitAmount>0)
			unitAmount+=0.000001;
		if(unitAmount<0)
			unitAmount-=0.000001;
		
			if(((long)((unitAmount)*100 ))*10!=(long)((unitAmount)*1000) )
				throw (new Exception("每箱件数小数精度不能大于2位unitAmount="+unitAmount.ToString()));
		if(unitAmount>0)
			unitAmount-=0.000001;
		if(unitAmount<0)
			unitAmount+=0.000001;
	

	//try{Convert.ToInt64(dealer);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	dealer<consts.long_min+1)
			throw (new Exception("请输入供应商"));

	//try{Convert.ToDouble(saleAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	saleAmount<consts.double_min+1)
			throw (new Exception("请输入销售数量"));
		if(saleAmount>0)
			saleAmount+=0.000001;
		if(saleAmount<0)
			saleAmount-=0.000001;
		
			if(((long)((saleAmount)*100 ))*10!=(long)((saleAmount)*1000) )
				throw (new Exception("销售数量小数精度不能大于2位saleAmount="+saleAmount.ToString()));
		if(saleAmount>0)
			saleAmount-=0.000001;
		if(saleAmount<0)
			saleAmount+=0.000001;
	

//do not check saleMoney 

	//try{Convert.ToDouble(returnedAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	returnedAmount<consts.double_min+1)
			throw (new Exception("请输入出库数量"));
		if(returnedAmount>0)
			returnedAmount+=0.000001;
		if(returnedAmount<0)
			returnedAmount-=0.000001;
		
			if(((long)((returnedAmount)*100 ))*10!=(long)((returnedAmount)*1000) )
				throw (new Exception("出库数量小数精度不能大于2位returnedAmount="+returnedAmount.ToString()));
		if(returnedAmount>0)
			returnedAmount-=0.000001;
		if(returnedAmount<0)
			returnedAmount+=0.000001;
	

//do not check returnedMoney 

	//try{Convert.ToDouble(storageAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	storageAmount<consts.double_min+1)
			throw (new Exception("请输入库存数量"));
		if(storageAmount>0)
			storageAmount+=0.000001;
		if(storageAmount<0)
			storageAmount-=0.000001;
		
			if(((long)((storageAmount)*100 ))*10!=(long)((storageAmount)*1000) )
				throw (new Exception("库存数量小数精度不能大于2位storageAmount="+storageAmount.ToString()));
		if(storageAmount>0)
			storageAmount-=0.000001;
		if(storageAmount<0)
			storageAmount+=0.000001;
	

//do not check storageMoney 

//do not check lossMoney 

	//try{Convert.ToDateTime(addTime);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	addTime.ToString().CompareTo(consts.datetime_min) <= 0 )
			throw (new Exception("请输入添加时间"));

	//try{Convert.ToInt32(settleState);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	settleState<consts.int_min+1)
			throw (new Exception("请输入结算状态"));

//unique="yes" 唯一性验证
    }
    public void checkUpdate()
    {
		int len;
	//try{Convert.ToInt64(seqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	seqID<consts.long_min+1)
			throw (new Exception("请输入编号"));
 if(				(				  string.Format("{0}",seqID)				  )=="0")
	 throw (new Exception("编号是主健，框架要求值不能为0"));				

	//try{Convert.ToDateTime(stockTime);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	stockTime.ToString().CompareTo(consts.datetime_min) <= 0 )
			throw (new Exception("请输入入库时间"));

	//try{Convert.ToInt64(commoditySeqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	commoditySeqID<consts.long_min+1)
			throw (new Exception("请输入商品编号"));

	
	len=commodityID.Trim().Length;
	if(len>50)
		 throw (new Exception("商品条形码字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品条形码不能为空!"));	
	

	
	len=commodityName.Trim().Length;
	if(len>50)
		 throw (new Exception("商品名称字符长度最长不能超过50,当前长度为"+len.ToString()));	
	

	//try{Convert.ToDouble(stockBoxAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	stockBoxAmount<consts.double_min+1)
			throw (new Exception("请输入箱数"));
		if(stockBoxAmount>0)
			stockBoxAmount+=0.000001;
		if(stockBoxAmount<0)
			stockBoxAmount-=0.000001;
		
			if(((long)((stockBoxAmount)*100 ))*10!=(long)((stockBoxAmount)*1000) )
				throw (new Exception("箱数小数精度不能大于2位stockBoxAmount="+stockBoxAmount.ToString()));
		if(stockBoxAmount>0)
			stockBoxAmount-=0.000001;
		if(stockBoxAmount<0)
			stockBoxAmount+=0.000001;
	

	//try{Convert.ToDouble(stockAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	stockAmount<consts.double_min+1)
			throw (new Exception("请输入进货数量"));
		if(stockAmount>0)
			stockAmount+=0.000001;
		if(stockAmount<0)
			stockAmount-=0.000001;
		
			if(((long)((stockAmount)*100 ))*10!=(long)((stockAmount)*1000) )
				throw (new Exception("进货数量小数精度不能大于2位stockAmount="+stockAmount.ToString()));
		if(stockAmount>0)
			stockAmount-=0.000001;
		if(stockAmount<0)
			stockAmount+=0.000001;
	

//do not check stockMoney 

	//try{Convert.ToDouble(stockPrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	stockPrice<consts.double_min+1)
			throw (new Exception("请输入进货价格"));
		if(stockPrice>0)
			stockPrice+=0.000001;
		if(stockPrice<0)
			stockPrice-=0.000001;
		
			if(((long)((stockPrice)*100 ))*10!=(long)((stockPrice)*1000) )
				throw (new Exception("进货价格小数精度不能大于2位stockPrice="+stockPrice.ToString()));
		if(stockPrice>0)
			stockPrice-=0.000001;
		if(stockPrice<0)
			stockPrice+=0.000001;
	

	//try{Convert.ToDouble(unitAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	unitAmount<consts.double_min+1)
			throw (new Exception("请输入每箱件数"));
		if(unitAmount>0)
			unitAmount+=0.000001;
		if(unitAmount<0)
			unitAmount-=0.000001;
		
			if(((long)((unitAmount)*100 ))*10!=(long)((unitAmount)*1000) )
				throw (new Exception("每箱件数小数精度不能大于2位unitAmount="+unitAmount.ToString()));
		if(unitAmount>0)
			unitAmount-=0.000001;
		if(unitAmount<0)
			unitAmount+=0.000001;
	

	//try{Convert.ToInt64(dealer);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	dealer<consts.long_min+1)
			throw (new Exception("请输入供应商"));

	//try{Convert.ToDouble(saleAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	saleAmount<consts.double_min+1)
			throw (new Exception("请输入销售数量"));
		if(saleAmount>0)
			saleAmount+=0.000001;
		if(saleAmount<0)
			saleAmount-=0.000001;
		
			if(((long)((saleAmount)*100 ))*10!=(long)((saleAmount)*1000) )
				throw (new Exception("销售数量小数精度不能大于2位saleAmount="+saleAmount.ToString()));
		if(saleAmount>0)
			saleAmount-=0.000001;
		if(saleAmount<0)
			saleAmount+=0.000001;
	

//do not check saleMoney 

	//try{Convert.ToDouble(returnedAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	returnedAmount<consts.double_min+1)
			throw (new Exception("请输入出库数量"));
		if(returnedAmount>0)
			returnedAmount+=0.000001;
		if(returnedAmount<0)
			returnedAmount-=0.000001;
		
			if(((long)((returnedAmount)*100 ))*10!=(long)((returnedAmount)*1000) )
				throw (new Exception("出库数量小数精度不能大于2位returnedAmount="+returnedAmount.ToString()));
		if(returnedAmount>0)
			returnedAmount-=0.000001;
		if(returnedAmount<0)
			returnedAmount+=0.000001;
	

//do not check returnedMoney 

	//try{Convert.ToDouble(storageAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	storageAmount<consts.double_min+1)
			throw (new Exception("请输入库存数量"));
		if(storageAmount>0)
			storageAmount+=0.000001;
		if(storageAmount<0)
			storageAmount-=0.000001;
		
			if(((long)((storageAmount)*100 ))*10!=(long)((storageAmount)*1000) )
				throw (new Exception("库存数量小数精度不能大于2位storageAmount="+storageAmount.ToString()));
		if(storageAmount>0)
			storageAmount-=0.000001;
		if(storageAmount<0)
			storageAmount+=0.000001;
	

//do not check storageMoney 

//do not check lossMoney 

	//try{Convert.ToDateTime(addTime);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	addTime.ToString().CompareTo(consts.datetime_min) <= 0 )
			throw (new Exception("请输入添加时间"));

	//try{Convert.ToInt32(settleState);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	settleState<consts.int_min+1)
			throw (new Exception("请输入结算状态"));

//unique="yes" 唯一性验证
		ICriterion crit=Restrictions.Eq("seqID", seqID);
  		IList list=dao.List(dao.DC.Add(crit));
		if(list.Count==1)
			return;
		if(list.Count==0)
			throw (new Exception("该记录已经被删除"));	
		else
			throw (new Exception("改纪录出现重名!"));
    }
    public void add()
    {
        try
        {
            checkAdd();
         	dao.Add(__hstock);
        }
        catch(Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
   
    public void delByseqID()
    {
    
        try
        {
          dao.Delete(__hstock);
        }
        catch(Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }

    public  void update()
    {
        try
        {
            checkUpdate();
            dao.Update(__hstock);
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
   
    public void ExecDataUpdate(int rowNo)
    {
		if(m_updateRow==null)
			return;
		int ii=0;
m_updateRow(rowNo,ii++,				(				  string.Format("{0}",seqID)				  ));	
m_updateRow(rowNo,ii++,			stockTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",stockTime));	
m_updateRow(rowNo,ii++,commodityID);	
m_updateRow(rowNo,ii++,commodityName);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",stockAmount)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",stockMoney)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",stockPrice)/***/)
);	
		Dealer p0 =((DealerDao)SpringContext.Context.GetObject("DealerDao")).Get(
		((DealerDao)SpringContext.Context.GetObject("DealerDao")).DC.Add(Restrictions.Eq("seqID",dealer)));
		
		if(p0==null)
			 m_updateRow(rowNo,ii++,				(				  string.Format("{0}",dealer)				  ));
		else
			m_updateRow(rowNo,ii++,p0.companyName.ToString());
     m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",saleAmount)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",saleMoney)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",returnedAmount)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",returnedMoney)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",storageAmount)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F0}",storageMoney)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",lossMoney)/***/)
);	
m_updateRow(rowNo,ii++,			addTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",addTime));	

    }
    public void ExecHeadInsert()
    {
		if(m_insertHead!=null)
        {
			int ii=0;
			m_insertHead(ii++,50,"编号");
			m_insertHead(ii++,150,"入库时间");
			m_insertHead(ii++,150,"商品条形码");
			m_insertHead(ii++,320,"商品名称");
			m_insertHead(ii++,90,"进货数量");
			m_insertHead(ii++,90,"进货金额");
			m_insertHead(ii++,90,"进货价格");
			m_insertHead(ii++,200,"供应商");
			m_insertHead(ii++,90,"销售数量");
			m_insertHead(ii++,90,"销售金额");
			m_insertHead(ii++,90,"出库数量");
			m_insertHead(ii++,90,"出库金额");
			m_insertHead(ii++,90,"库存数量");
			m_insertHead(ii++,90,"库存金额");
			m_insertHead(ii++,90,"损耗金额");
			m_insertHead(ii++,140,"添加时间");
		}		
    }
    public void ExecDataInsert()
	{
		if(m_insertRow==null)
			return;
		int ii=0;
     	m_insertRow(0,ii++,				(				  string.Format("{0}",seqID)				  ));
     	m_insertRow(0,ii++,			stockTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",stockTime));
     	m_insertRow(0,ii++,commodityID);
     	m_insertRow(0,ii++,commodityName);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",stockAmount)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",stockMoney)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",stockPrice)/***/)
);
		DealerDao dao0=(SpringContext.Context.GetObject("DealerDao") as DealerDao);
        Dealer p0 =  dao0.Get(dao0.DC.Add(Restrictions.Eq("seqID",dealer)));
		if(p0!=null)
			 m_insertRow(0,ii++,p0.companyName.ToString());
		else
			m_insertRow(0,ii++,				(				  string.Format("{0}",dealer)				  ));
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",saleAmount)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",saleMoney)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",returnedAmount)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",returnedMoney)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",storageAmount)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F0}",storageMoney)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",lossMoney)/***/)
);
     	m_insertRow(0,ii++,			addTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",addTime));
    }
    public void ExecDataInsertByQuery(DetachedCriteria dc)
    {
      
         IList list=dao.List(dc); 
        
        if(m_insertHead!=null)
        {
			int ii=0;
			m_insertHead(ii++,50,"编号");
			m_insertHead(ii++,150,"入库时间");
			m_insertHead(ii++,150,"商品条形码");
			m_insertHead(ii++,320,"商品名称");
			m_insertHead(ii++,90,"进货数量");
			m_insertHead(ii++,90,"进货金额");
			m_insertHead(ii++,90,"进货价格");
			m_insertHead(ii++,200,"供应商");
			m_insertHead(ii++,90,"销售数量");
			m_insertHead(ii++,90,"销售金额");
			m_insertHead(ii++,90,"出库数量");
			m_insertHead(ii++,90,"出库金额");
			m_insertHead(ii++,90,"库存数量");
			m_insertHead(ii++,90,"库存金额");
			m_insertHead(ii++,90,"损耗金额");
			m_insertHead(ii++,140,"添加时间");
		}		
		
      if(m_insertRow!=null)
      {
        int j=0;
        foreach(Hstock obj in list)			
        {
		  int ii=0;
	     
m_insertRow(j,ii++,				(				  string.Format("{0}",obj.seqID)
				  )
);
m_insertRow(j,ii++,			obj.stockTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",obj.stockTime)
);
m_insertRow(j,ii++,obj.commodityID.ToString());
m_insertRow(j,ii++,obj.commodityName.ToString());
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.stockAmount)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.stockMoney)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.stockPrice)
					)
);
		DealerDao dao0=(SpringContext.Context.GetObject("DealerDao") as DealerDao);
        Dealer p0 =  dao0.Get(dao0.DC.Add(Restrictions.Eq("seqID",obj.dealer)));
		if(p0!=null)
			 m_insertRow(j,ii++,p0.companyName.ToString());
		else
m_insertRow(j,ii++,				(				  string.Format("{0}",obj.dealer)
				  )
);

m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.saleAmount)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.saleMoney)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.returnedAmount)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.returnedMoney)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.storageAmount)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F0}",obj.storageMoney)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.lossMoney)
					)
);
m_insertRow(j,ii++,			obj.addTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",obj.addTime)
);
		j++;
        }
        

	
       }
    }

    
    public IList List(DetachedCriteria dc)
    {
        try
        {
           
            return dao.List(dc);
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
    
    public bool Init(DetachedCriteria dc)
    {
    
    		Hstock obj=dao.Get(dc);
    		if(obj==null)
    			return false;
    		else
    		{
    			__hstock=obj;
            	return true;
            }
        
    }
    public static t_hstock Get(DetachedCriteria dc)
    {
    	
    	Hstock obj=((HstockDao)SpringContext.Context.GetObject("HstockDao"))
	 	.Get(dc);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_hstock( obj );
        
    }
	 public static t_hstock GetBySeqID(long val)
	 {
	 	Hstock obj=((HstockDao)SpringContext.Context.GetObject("HstockDao"))
	 	.GetBySeqID(val);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_hstock( obj );
	 	
	 	
	 }
	 public  bool InitBySeqID(long val)
	 {
	 	

	 	Hstock obj=dao.GetBySeqID(val) ;
	 	if(obj==null)
	 		return false;
	 	else
	 	{
	 		__hstock=obj;
	 		return true;
	 	}
	 	
	 	
	 }
    
       public bool showInForm(Control.ControlCollection Controls)
    {
        try
        {
             
		if(Controls["seqID"]!=null)
		{
			Controls["seqID"].Text=				(				  string.Format("{0}",seqID)				  );
		}
		if(Controls["stockTime"]!=null)
		{
			Controls["stockTime"].Text=			stockTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",stockTime);
		}
		if(Controls["commoditySeqID"]!=null)
		{
			Controls["commoditySeqID"].Text=				(				  string.Format("{0}",commoditySeqID)				  );
		}
		if(Controls["commodityID"]!=null)
		{
			Controls["commodityID"].Text=commodityID;
		}
		if(Controls["commodityName"]!=null)
		{
			Controls["commodityName"].Text=commodityName;
		}
		if(Controls["stockBoxAmount"]!=null)
		{
			Controls["stockBoxAmount"].Text=/***/(						string.Format("{0:F2}",stockBoxAmount)/***/)
;
		}
		if(Controls["stockAmount"]!=null)
		{
			Controls["stockAmount"].Text=/***/(						string.Format("{0:F2}",stockAmount)/***/)
;
		}
		if(Controls["stockMoney"]!=null)
		{
			Controls["stockMoney"].Text=/***/(						string.Format("{0:F2}",stockMoney)/***/)
;
		}
		if(Controls["stockPrice"]!=null)
		{
			Controls["stockPrice"].Text=/***/(						string.Format("{0:F2}",stockPrice)/***/)
;
		}
		if(Controls["unitAmount"]!=null)
		{
			Controls["unitAmount"].Text=/***/(						string.Format("{0:F2}",unitAmount)/***/)
;
		}
		if(Controls["dealer"]!=null)
		{
			Controls["dealer"].Text=				(				  string.Format("{0}",dealer)				  );
		}
		if(Controls["saleAmount"]!=null)
		{
			Controls["saleAmount"].Text=/***/(						string.Format("{0:F2}",saleAmount)/***/)
;
		}
		if(Controls["saleMoney"]!=null)
		{
			Controls["saleMoney"].Text=/***/(						string.Format("{0:F2}",saleMoney)/***/)
;
		}
		if(Controls["returnedAmount"]!=null)
		{
			Controls["returnedAmount"].Text=/***/(						string.Format("{0:F2}",returnedAmount)/***/)
;
		}
		if(Controls["returnedMoney"]!=null)
		{
			Controls["returnedMoney"].Text=/***/(						string.Format("{0:F2}",returnedMoney)/***/)
;
		}
		if(Controls["storageAmount"]!=null)
		{
			Controls["storageAmount"].Text=/***/(						string.Format("{0:F2}",storageAmount)/***/)
;
		}
		if(Controls["storageMoney"]!=null)
		{
			Controls["storageMoney"].Text=/***/(						string.Format("{0:F0}",storageMoney)/***/)
;
		}
		if(Controls["lossMoney"]!=null)
		{
			Controls["lossMoney"].Text=/***/(						string.Format("{0:F2}",lossMoney)/***/)
;
		}
		if(Controls["addTime"]!=null)
		{
			Controls["addTime"].Text=			addTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",addTime);
		}
		if(Controls["settleState"]!=null)
		{
			Controls["settleState"].Text=	t_hstock.enum_settleState[settleState.ToString()].ToString()
;
		}
			return true;
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
            
        }
    }
    public  t_hstock Init(Hstock item)
    {
        __hstock=item;
        return this;
    }

    
     public bool initByForm(Control.ControlCollection Controls)
    {
        try
        {
             
		if(Controls["seqID"]!=null)
		{
			
			if(Controls["seqID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["seqID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{seqID=(v==""?consts.long_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["seqID"].Focus();
					throw  (new Exception("编号格式不正确！！"));
				}
				
			}
			else
			{
				try{seqID=(Controls["seqID"].Text==""?consts.long_min:Convert.ToInt32(Controls["seqID"].Text));}
				catch
				{
					 Controls["seqID"].Focus();
					throw  (new Exception("编号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["stockTime"]!=null)
		{
			
			if(Controls["stockTime"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["stockTime"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{stockTime=(v==""?new DateTime(1000,1,1):Convert.ToDateTime(v));}
				catch
				{
					 Controls["stockTime"].Focus();
					throw  (new Exception("入库时间格式不正确！！"));
				}
				
			}
			else
			{
				try{stockTime=(Controls["stockTime"].Text==""?new DateTime(1000,1,1):Convert.ToDateTime(Controls["stockTime"].Text));}
				catch
				{
					 Controls["stockTime"].Focus();
					throw  (new Exception("入库时间格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commoditySeqID"]!=null)
		{
			
			if(Controls["commoditySeqID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commoditySeqID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commoditySeqID=(v==""?consts.long_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["commoditySeqID"].Focus();
					throw  (new Exception("商品编号格式不正确！！"));
				}
				
			}
			else
			{
				try{commoditySeqID=(Controls["commoditySeqID"].Text==""?consts.long_min:Convert.ToInt32(Controls["commoditySeqID"].Text));}
				catch
				{
					 Controls["commoditySeqID"].Focus();
					throw  (new Exception("商品编号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityID"]!=null)
		{
			
			if(Controls["commodityID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityID=v;}
				catch
				{
					 Controls["commodityID"].Focus();
					throw  (new Exception("商品条形码格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityID=Controls["commodityID"].Text;}
				catch
				{
					 Controls["commodityID"].Focus();
					throw  (new Exception("商品条形码格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityName"]!=null)
		{
			
			if(Controls["commodityName"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityName"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityName=v;}
				catch
				{
					 Controls["commodityName"].Focus();
					throw  (new Exception("商品名称格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityName=Controls["commodityName"].Text;}
				catch
				{
					 Controls["commodityName"].Focus();
					throw  (new Exception("商品名称格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["stockBoxAmount"]!=null)
		{
			
			if(Controls["stockBoxAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["stockBoxAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{stockBoxAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["stockBoxAmount"].Focus();
					throw  (new Exception("箱数格式不正确！！"));
				}
				
			}
			else
			{
				try{stockBoxAmount=(Controls["stockBoxAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["stockBoxAmount"].Text));}
				catch
				{
					 Controls["stockBoxAmount"].Focus();
					throw  (new Exception("箱数格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["stockAmount"]!=null)
		{
			
			if(Controls["stockAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["stockAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{stockAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["stockAmount"].Focus();
					throw  (new Exception("进货数量格式不正确！！"));
				}
				
			}
			else
			{
				try{stockAmount=(Controls["stockAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["stockAmount"].Text));}
				catch
				{
					 Controls["stockAmount"].Focus();
					throw  (new Exception("进货数量格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["stockMoney"]!=null)
		{
			
			if(Controls["stockMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["stockMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{stockMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["stockMoney"].Focus();
					throw  (new Exception("进货金额格式不正确！！"));
				}
				
			}
			else
			{
				try{stockMoney=(Controls["stockMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["stockMoney"].Text));}
				catch
				{
					 Controls["stockMoney"].Focus();
					throw  (new Exception("进货金额格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["stockPrice"]!=null)
		{
			
			if(Controls["stockPrice"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["stockPrice"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{stockPrice=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["stockPrice"].Focus();
					throw  (new Exception("进货价格格式不正确！！"));
				}
				
			}
			else
			{
				try{stockPrice=(Controls["stockPrice"].Text==""?consts.double_min:Convert.ToDouble(Controls["stockPrice"].Text));}
				catch
				{
					 Controls["stockPrice"].Focus();
					throw  (new Exception("进货价格格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["unitAmount"]!=null)
		{
			
			if(Controls["unitAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["unitAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{unitAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["unitAmount"].Focus();
					throw  (new Exception("每箱件数格式不正确！！"));
				}
				
			}
			else
			{
				try{unitAmount=(Controls["unitAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["unitAmount"].Text));}
				catch
				{
					 Controls["unitAmount"].Focus();
					throw  (new Exception("每箱件数格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["dealer"]!=null)
		{
			
			if(Controls["dealer"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["dealer"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{dealer=(v==""?consts.long_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["dealer"].Focus();
					throw  (new Exception("供应商格式不正确！！"));
				}
				
			}
			else
			{
				try{dealer=(Controls["dealer"].Text==""?consts.long_min:Convert.ToInt32(Controls["dealer"].Text));}
				catch
				{
					 Controls["dealer"].Focus();
					throw  (new Exception("供应商格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["saleAmount"]!=null)
		{
			
			if(Controls["saleAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["saleAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{saleAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["saleAmount"].Focus();
					throw  (new Exception("销售数量格式不正确！！"));
				}
				
			}
			else
			{
				try{saleAmount=(Controls["saleAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["saleAmount"].Text));}
				catch
				{
					 Controls["saleAmount"].Focus();
					throw  (new Exception("销售数量格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["saleMoney"]!=null)
		{
			
			if(Controls["saleMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["saleMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{saleMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["saleMoney"].Focus();
					throw  (new Exception("销售金额格式不正确！！"));
				}
				
			}
			else
			{
				try{saleMoney=(Controls["saleMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["saleMoney"].Text));}
				catch
				{
					 Controls["saleMoney"].Focus();
					throw  (new Exception("销售金额格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["returnedAmount"]!=null)
		{
			
			if(Controls["returnedAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["returnedAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{returnedAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["returnedAmount"].Focus();
					throw  (new Exception("出库数量格式不正确！！"));
				}
				
			}
			else
			{
				try{returnedAmount=(Controls["returnedAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["returnedAmount"].Text));}
				catch
				{
					 Controls["returnedAmount"].Focus();
					throw  (new Exception("出库数量格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["returnedMoney"]!=null)
		{
			
			if(Controls["returnedMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["returnedMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{returnedMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["returnedMoney"].Focus();
					throw  (new Exception("出库金额格式不正确！！"));
				}
				
			}
			else
			{
				try{returnedMoney=(Controls["returnedMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["returnedMoney"].Text));}
				catch
				{
					 Controls["returnedMoney"].Focus();
					throw  (new Exception("出库金额格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["storageAmount"]!=null)
		{
			
			if(Controls["storageAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["storageAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{storageAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["storageAmount"].Focus();
					throw  (new Exception("库存数量格式不正确！！"));
				}
				
			}
			else
			{
				try{storageAmount=(Controls["storageAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["storageAmount"].Text));}
				catch
				{
					 Controls["storageAmount"].Focus();
					throw  (new Exception("库存数量格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["storageMoney"]!=null)
		{
			
			if(Controls["storageMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["storageMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{storageMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["storageMoney"].Focus();
					throw  (new Exception("库存金额格式不正确！！"));
				}
				
			}
			else
			{
				try{storageMoney=(Controls["storageMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["storageMoney"].Text));}
				catch
				{
					 Controls["storageMoney"].Focus();
					throw  (new Exception("库存金额格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["lossMoney"]!=null)
		{
			
			if(Controls["lossMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["lossMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{lossMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["lossMoney"].Focus();
					throw  (new Exception("损耗金额格式不正确！！"));
				}
				
			}
			else
			{
				try{lossMoney=(Controls["lossMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["lossMoney"].Text));}
				catch
				{
					 Controls["lossMoney"].Focus();
					throw  (new Exception("损耗金额格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["addTime"]!=null)
		{
			
			if(Controls["addTime"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["addTime"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{addTime=(v==""?new DateTime(1000,1,1):Convert.ToDateTime(v));}
				catch
				{
					 Controls["addTime"].Focus();
					throw  (new Exception("添加时间格式不正确！！"));
				}
				
			}
			else
			{
				try{addTime=(Controls["addTime"].Text==""?new DateTime(1000,1,1):Convert.ToDateTime(Controls["addTime"].Text));}
				catch
				{
					 Controls["addTime"].Focus();
					throw  (new Exception("添加时间格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["settleState"]!=null)
		{
			
			if(Controls["settleState"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["settleState"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{settleState=(v==""?consts.int_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["settleState"].Focus();
					throw  (new Exception("结算状态格式不正确！！"));
				}
				
			}
			else
			{
				try{settleState=(Controls["settleState"].Text==""?consts.int_min:Convert.ToInt32(Controls["settleState"].Text));}
				catch
				{
					 Controls["settleState"].Focus();
					throw  (new Exception("结算状态格式不正确！！"));
				}
				
			}
				
				
		}
			return true;
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
            
        }
    }
    

}

}
